package org.rcgwt.client.ui.calendar.event;

import java.util.Date;

import org.rcgwt.client.ui.calendar.model.impl.EventType;

import com.google.gwt.event.shared.GwtEvent;

public class InvalidDateEvent extends GwtEvent<InvalidDateHandler> {

	private static final GwtEvent.Type<InvalidDateHandler> TYPE = new GwtEvent.Type<InvalidDateHandler>();
	private Date date;
	private EventType eventType;

	public InvalidDateEvent(Date d, EventType e) {
		this.setDate(d);
		this.setEventType(e);
	}

	@Override
	protected void dispatch(InvalidDateHandler handler) {
		handler.onInvalidDate(this);
	}

	public static void fire(HasInvalidDateHandlers source, Date d, EventType e) {
		if (TYPE != null) {
			InvalidDateEvent event = new InvalidDateEvent(d, e);
			source.fireEvent(event);
		}
	}

	@Override
	public GwtEvent.Type<InvalidDateHandler> getAssociatedType() {
		return TYPE;
	}

	public static GwtEvent.Type<InvalidDateHandler> getType() {
		return TYPE;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getDate() {
		return date;
	}

	public void setEventType(EventType eventType) {
		this.eventType = eventType;
	}

	public EventType getEventType() {
		return eventType;
	}
}
